<?php

namespace App\Admin\Extensions;

use Encore\Admin\Admin;

class OrderDeliver
{
    protected $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

    protected function script()
    {
        return <<<SCRIPT

$('.grid-order-deliver').on('click', function () {

    // Your code.
    console.log($(this).data('id'));
    var id = $(this).data('id');
    $.get("./order/goodsDeliver/"+id, function(result){
    	Swal.fire('这是测试').then((result) => {
		  window.location.reload();
		})
	});
	
});

SCRIPT;
    }

    protected function render()
    {
        Admin::script($this->script());

        return "<a class='btn btn-xs btn-default grid-order-deliver' data-id='{$this->id}' href=''><i class='fa fa-paper-plane'>已发货</i></a>";
    }

    public function __toString()
    {
        return $this->render();
    }
}